<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 *bph_area省市区模型
 */
class Area_model extends CI_Model{
	const TBL_AREA='area';
	/**
	*author mhp
	*date 2015-11-20
	*根据parent_id获得省市区
	*@param  Integer $type 顶级type，省parent_id为1
	*@return array
	*/
	public function list_area($type){
		$condition['type'] = $type;
		$query = $this->db->where($condition)->get(self::TBL_AREA);
		return $query->result_array();
	}
	//获取where条件下的数据返回result对象
	public function get_where_result($where){
		$query = $this->db->select('*')->where($where)->get(self::TBL_AREA);
		return $query->result_array();
	}

	/**
	*根据id获取省市区信息
	*/
	public function get_area($id){
		$condition['id'] = $id;
		$query = $this->db->where($condition)->get(self::TBL_AREA);
		return $query->row_array();
	}
}